<template>
      <!-- AI生成器的容器，根据isFullscreen状态添加fullscreen类 -->
    <div class="ai-generator-container" :class="{ 'fullscreen': isFullscreen }">
      <!-- AI生成器的内容区域 -->
      <div class="ai-generator-content">

        <!-- 生成结果面板 -->
        <div class="result-panel" :class="{ 'expanded': true }">
          <!-- 结果面板头部 -->
          <div class="result-header">
            <!-- 结果面板标题，使用Font Awesome图标 -->
            <h3><i class="fas fa-magic"></i> 题目列表</h3>
            <!-- 结果统计信息 -->
            <div class="result-stats">
              <!-- 遍历selectedTypes生成统计项 -->
              <div class="stat-item" v-for="type in selectedTypes" :key="type">
                <!-- 统计徽章，根据typeColors设置背景颜色 -->
                <span class="stat-badge" :style="{ backgroundColor: getTypeColor(type) }">
                  {{ getTypeName(type) }}
                </span>
                <!-- 题目数量 -->
                <span class="stat-count">{{ getPreviewCount(type) }}</span>
              </div>
            </div>
            <div class="header-actions">
              <!-- 保存按钮 -->
              <button class="btn-save" @click="saveQuestions">
                <span class="btn-content">
                  <i class="fas fa-save"></i>
                  <span class="btn-text">保存题目</span>
                </span>
              </button>
              
              <!-- 退出按钮 -->
              <button class="btn-exit" @click="exit">
                <span class="btn-content">
                  <i class="fas fa-sign-out-alt"></i>
                  <span class="btn-text">退出</span>
                </span>
              </button>
            </div>
          </div>

          <!-- 结果面板内容 -->
          <div class="result-content">
            <!-- 错误提示，仅在error存在时显示 -->
            <div v-if="error" class="error-message">
              <!-- Font Awesome图标 -->
              <i class="fas fa-exclamation-triangle"></i>
              <!-- 错误信息 -->
              {{ error }}
            </div>

            <!-- 题目预览区域 -->
            <div class="questions-preview" v-if="previewQuestions && previewQuestions.length > 0">
              <div v-for="(q, idx) in previewQuestions"
                   :key="idx"
                   class="question-card"
                   :class="[getNumberType(q.type), { 'regenerating': q.isRegenerating }]">
                <!-- 删除按钮 -->
                <div class="delete-btn" @click="removeQuestion(idx)" title="删除此题目">
                        <i class="fas fa-trash-alt"></i>
                    </div>
                
                <!-- 重新生成中文本 -->
                <div class="generating-text" v-if="q.isRegenerating">正在生成中...</div>

                <!-- 题目头部 -->
                <div class="question-header">
                    <!-- 题目序号 -->
                    <div class="question-number">{{ idx + 1 }}.</div>
                                  
                  <!-- 题目类型徽章 -->
                  <span class="question-type" :style="{ backgroundColor: getTypeColor(q.type) }">
                    {{ getTypeName(q.type) }}
                  </span>
                  
                  <!-- 题目难度徽章 -->
                  <span class="question-difficulty" :style="getDifficultyStyle(q.difficulty)">
                    {{ getDifficultyName(q.difficulty) }}
                  </span>
                </div>

                <!-- 题目内容 -->
                <div class="question-content">
                  {{ q.content }}
                </div>

                <!-- 选项列表 -->
                <div class="question-options" v-if="q.options">
                  <div v-for="(option, optIdx) in q.options.split(',')"
                       :key="optIdx"
                       class="option-item"
                       :class="{ 'correct': isCorrectAnswer(q, option) }">
                    <!-- 正确答案指示器 -->
                    <div v-if="isCorrectAnswer(q, option)" class="correct-indicator">
                      <i class="fas fa-check-circle"></i>
                    </div>
                    <!-- 选项内容 -->
                    <div class="option-content">
                      {{ String.fromCharCode(65 + optIdx) }}. {{ option.trim() }}
                    </div>
                  </div>
                </div>

                <!-- 题目底部 -->
                <div class="question-footer">
                  <!-- 参考答案部分 -->
                  <div class="answer-section" v-if="q.correctAnswer && q.type !== 'shortanswer'">
                      <span class="answer-label">参考答案:</span>
                      <span class="answer-value">{{ formatAnswer(q) }}</span>
                    </div>
                                  
                    <!-- 答案解析部分 -->
                    <div class="parse-section" v-if="q.parse">
                      <div class="parse-title">
                        <i class="fas fa-lightbulb"></i> 答案解析
                      </div>
                      <div class="parse-content">
                        {{ q.parse }}
                      </div>
                    </div>
                    <div class="footer-actions">
                      <div class="ai-generated">
                        <div class="ai-icon">
                          <i class="fas fa-robot"></i>
                        </div>
                        <span class="ai-text">AI生成</span>
                      </div>
                      <button class="btn-regenerate" 
                              :class="{ 'loading': q.isRegenerating }" 
                              @click="regenerateQuestions(q)"
                              :disabled="q.isRegenerating">
                        <i :class="q.isRegenerating ? 'fas fa-spinner fa-spin' : 'fas fa-sync-alt'"></i>
                        {{ q.isRegenerating ? '重新生成中...' : '重新生成' }}
                      </button>
                    </div>
                </div>
              </div>
            </div>

            <!-- 空状态 -->
            <div v-else class="empty-state">
              <div class="empty-illustration">
                <i class="fas fa-lightbulb"></i>
              </div>
              <h4>等待题目加载</h4>
              <p>题目数据加载中...</p>
            </div>
          </div>
        </div>
      </div>
    </div>
</template>

<script>
// 导入Vuex的mapActions和mapMutations辅助函数
import { mapActions, mapMutations, mapState } from 'vuex';


export default {
  // 组件名称
  name: 'AIBankResultHeader',
  // 组件数据
  data() {
    return {
          // 全屏状态标记
      isFullscreen: false,
      // 题目列表 - 初始化为空数组
      previewQuestions: [],
      // 路由数据
      routeData: null,
      // 错误信息
      error: null,
      // 题目展示配置
      isGenerating: false,
      generating: false,
      displayConfig: {
        showDifficulty: true,
        showType: true,
        showParse: true
      }
    }
  },
  
  // 计算属性
  computed: {
    ...mapState({
      regeneratedQuestion: state => state.question.regeneratedQuestion
    }),
    // 按题型分组的题目统计
    questionStats() {
      const stats = {};
      this.previewQuestions.forEach(q => {
        if (!stats[q.type]) {
          stats[q.type] = {
            count: 0,
            name: this.getTypeName(q.type)
          };
        }
        stats[q.type].count++;
      });
      return stats;
    },
    // 选中的题型
    selectedTypes() {
      // 从预览题目中获取所有不重复的题型
      return [...new Set(this.previewQuestions.map(q => q.type))];
    },
    // 是否可以开始生成
    canGenerate() {
          const hasReferenceFile = !!this.referenceFile;
          
      return (
              // 如果有参考文件，则不需要关键词和题库名称
              (hasReferenceFile || 
                  // 否则主题/关键词不为空且题库名称不为空
                  (this.config.keywords.trim().length > 0 && this.bankData.name.trim().length > 0)
              ) &&
          // 总题目数量大于0
          this.totalQuestions > 0 &&
              // 总题目数量不超过50
              this.totalQuestions <= 50
      )
    },
    // 总题目数量
    totalQuestions() {
      return Object.values(this.config.questionTypes).reduce((a, b) => a + b, 0)
      },
      // 过滤后的关键词标签
      filteredKeywordTags() {
          return this.keywordTags.filter(tag => tag && tag.length > 0);
      },
      ...mapState({
        regeneratedQuestion: state => state.question.regeneratedQuestion
      })
  },
  // 监听属性
  watch: {
      'config.keywords': {
          handler(newVal) {
              if (newVal) {
                  this.keywordTags = newVal.split(/[,，、]/)
                      .map(k => k.trim())
                      .filter(k => k.length > 0);
              } else {
                  this.keywordTags = [];
              }
          },
          immediate: true
      },
      // 监听重新生成的题目
      regeneratedQuestion: {
        handler(newQuestion) {
          console.log('newQuestion', newQuestion);
          if (newQuestion && this.previewQuestions) {
            // 找到对应的题目并更新
            const index = this.previewQuestions.findIndex(q => +q.index === +newQuestion.index);
            if (index !== -1) {
              // 使用 Vue 的响应式方法更新题目
              this.$set(this.previewQuestions[index], 'content', newQuestion.content);
              this.$set(this.previewQuestions[index], 'options', newQuestion.options);
              this.$set(this.previewQuestions[index], 'correctAnswer', newQuestion.correctAnswer);
              this.$set(this.previewQuestions[index], 'parse', newQuestion.parse);
              // 难度
              this.$set(this.previewQuestions[index], 'difficulty', newQuestion.difficulty);
              // 题型
              this.$set(this.previewQuestions[index], 'type', newQuestion.type);
              // 生成状态
              this.$set(this.previewQuestions[index], 'isRegenerating', false);
              // 显示成功提示
              this.$message({
                type: 'success',
                message: '题目重新生成成功',
                duration: 1500
              });
              // 重置 Vuex 中的状态
              this.$store.commit('question/UPDATE_REGENERATED_QUESTION', null);
            }
          }
        },
        immediate: true
      }
  },
  // 组件销毁前的生命周期钩子
  beforeDestroy() {
      // 清理临时生成标记
      if (!this.createdBankId) {
          // 如果没有最终创建题库，则清除临时标记
          localStorage.removeItem(`ai_generation_temp`);
      }
  },
  // 方法
  methods: {
  // 从Vuex引入相关方法
  ...mapMutations({
      addBankToStore: 'question/ADD_BANK',       // 添加题库到Vuex store
      addQuestionToStore: 'question/ADD_QUESTION' // 添加题目到Vuex store
  }),
  ...mapActions({
      fetchBanks: 'question/fetchBanks'          // 获取题库列表的action
  }),
  
    // 重新生成题目
  regenerateQuestions(question) {
    // 设置重新生成状态
    const index = this.previewQuestions.findIndex(q => q.index === question.index);
    if (index !== -1) {
      this.$set(this.previewQuestions[index], 'isRegenerating', true);
    }
    //  将题目的编号通过自定义提示词发送
    this.$store.dispatch('aiPanel/sendMessage', {
     prompt: `重新生成第${question.index}题`,
     silent: true  // 添加silent参数，表示不显示在对话界面
    });
  },

  // 保存题目方法
  saveQuestions() {
    if (this.previewQuestions.length === 0) {
      this.$message({
        type: 'warning',
        message: '没有可保存的题目',
        duration: 1500
      });
      return;
    }

     // 发送保存题目
     this.$store.dispatch('aiPanel/sendMessage', {
        prompt: `保存题目`,
        silent: true  // 添加silent参数，表示不显示在对话界面
     }).catch(() => {});
  },
  
  // 退出方法
  exit() {
    // 提示用户是否确认退出
    this.$confirm('确定要退出吗？未保存的题目将会丢失', '提示', {
      confirmButtonText: '确定退出',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      // 用户确认退出
      // 清空预览列表
      this.previewQuestions = [];
      // 重置所有配置
      this.resetAllConfig();
      // 显示成功提示
      this.$message({
        type: 'success',
        message: '已退出题目预览',
        duration: 1500
      });
      // 跳转到题库列表页面
      this.$router.push('/question-bank/bank-list');
    }).catch(() => {
      // 用户取消退出，不做任何操作
      this.$message({
        type: 'info',
        message: '已取消退出',
        duration: 1500
      });
    });
  },
      
  // 处理选项格式，确保选项格式一致
  processQuestionOptions(question) {
      // 已经处理过的题目不再处理
      if (question._optionsProcessed) return;
      
      // 获取规范化的题目类型
      const qType = this.getNumberType(question.type);
      
      // 确保选项不是undefined
      let options = question.options || '';
      
      // 处理选项格式
      if (qType === 'single' || qType === 'multiple') {
          // 确保选项是按行分隔，且以字母开头
          if (!options.includes('\n') && !options.startsWith('A.')) {
              const optArray = options.split(/[，,]/);
              options = optArray
                .filter(opt => opt && opt.trim().length > 0) // 过滤空选项
                .map((opt, idx) => {
                  const letter = String.fromCharCode(65 + idx);
                  return `${letter}.${opt.trim()}`;
                }).join('\n');
              // 使用Vue的响应式方法更新
              this.$set(question, 'options', options);
          }
      } else if (qType === 'truefalse') {
          // 确保判断题的选项格式正确
          this.$set(question, 'options', 'A.正确\nB.错误');
      }
      
      // 标记为已处理
      this.$set(question, '_optionsProcessed', true);
  },
      
    // 重置所有配置
    resetAllConfig() {
        // 重置题库基本信息
        this.bankData = {
            name: '',
            description: ''
        };
        
        // 重置配置信息
        this.config = {
            keywords: '',
            style: 'standard',
            difficulty: 'medium',
            questionTypes: {
                single: 0,
                multiple: 0,
                fillblank: 0,
                truefalse: 0,
                shortanswer: 0
            }
        };
        
        // 重置文件相关
        this.referenceFile = null;
        this.fileContent = null;
        
        // 重置预览列表
        this.previewQuestions = [];
        
        // 重置状态
        this.generating = false;
        this.progress = 0;
        this.error = null;
        
        // 清空选中的题库信息
        this.localSelectedBank = null;
        this.createdBankId = null;
        
        // 清空AI返回的题库信息
        this.aiReturnBank = {
            bankName: '',
            bankDescription: '',
            questions: []
        };
        
        // 重置关键词标签
        this.keywordTags = [];
        
        console.log("所有配置已重置");
    },
    
    // 重置生成状态
    resetGenerationState() {
        // 清除生成记录
        localStorage.removeItem(`ai_generation_${this.localBankId || 'temp'}`);
        
        // 清空已生成的题目
        this.previewQuestions = [];
        
        // 重置生成状态
        this.generating = false;
        this.isGenerating = false;
        this.progress = 0;
        this.error = null;
        
        this.$notify({
            title: '提示',
            message: '生成状态已重置，可以重新生成题目',
            type: 'info',
            duration: 3000
        });
    },
    
 
    // 获取题型描述
    getTypeDescription(type) {
      const descriptions = {
        single: '选择一个正确答案',
        multiple: '选择多个正确答案',
        truefalse: '判断陈述是否正确',
        fillblank: '填写空白处的答案'
      }
      return descriptions[type] || ''
    },
    // 将数字类型转换为字符串类型
    getNumberType(type) {
      // 如果type已经是字符串类型，则直接返回
      if (typeof type === 'string') {
        return type;
      }
      
      // 数字到字符串的映射
      const typeMap = {
        0: 'single',
        1: 'multiple',
        2: 'fillblank',
        3: 'truefalse',
        4: 'shortanswer'
      };
      
      return typeMap[type] || 'single'; // 默认返回single类型
    },
    // 获取题型名称
    getTypeName(type) {
      const typeNames = {
        0: '单选题',
        1: '多选题',
        2: '填空题',
        3: '判断题',
        4: '简答题',
        'single': '单选题',
        'multiple': '多选题',
        'fillblank': '填空题',
        'truefalse': '判断题',
        'shortanswer': '简答题'
      };
      return typeNames[type] || type;
    },
    // 获取难度名称
    getDifficultyName(difficulty) {
      // 处理数字类型的难度
      if (typeof difficulty === 'number') {
        if (difficulty >= 1 && difficulty <= 3) return '简单';
        if (difficulty >= 4 && difficulty <= 7) return '中等';
        if (difficulty >= 8 && difficulty <= 10) return '困难';
      }

      // 处理字符串类型的难度
      const difficultyNames = {
        'easy': '简单',
        'medium': '中等',
        'hard': '困难'
      };
      return difficultyNames[difficulty] || '中等';
    },
    // 获取难度样式
    getDifficultyStyle(difficulty) {
      // 处理数字类型的难度
      if (typeof difficulty === 'number') {
        if (difficulty >= 1 && difficulty <= 3) {
          return { backgroundColor: '#4CAF50', color: '#fff' }; // 简单 - 绿色
        }
        if (difficulty >= 4 && difficulty <= 7) {
          return { backgroundColor: '#FF9800', color: '#fff' }; // 中等 - 橙色
        }
        if (difficulty >= 8 && difficulty <= 10) {
          return { backgroundColor: '#F44336', color: '#fff' }; // 困难 - 红色
        }
      }

      // 处理字符串类型的难度
      const styles = {
        'easy': { backgroundColor: '#4CAF50', color: '#fff' },
        'medium': { backgroundColor: '#FF9800', color: '#fff' },
        'hard': { backgroundColor: '#F44336', color: '#fff' }
      };
      return styles[difficulty] || { backgroundColor: '#FF9800', color: '#fff' }; // 默认中等
    },
    // 获取题型颜色
    getTypeColor(type) {
      const typeColors = {
        0: '#4361EE', // 单选
        1: '#3A0CA3', // 多选
        2: '#9C27B0', // 填空
        3: '#FF9800', // 判断
        4: '#795548', // 简答
        'single': '#4361EE',
        'multiple': '#3A0CA3',
        'fillblank': '#9C27B0',
        'truefalse': '#FF9800',
        'shortanswer': '#795548'
      };
      return typeColors[type] || '#666666';
    },
    // 格式化答案
    formatAnswer(question) {
      if (!question.correctAnswer && !question.correct_answer) return '';
      
      const answer = question.correctAnswer || question.correct_answer;
      
      if (question.type === 1 || question.type === 'multiple') {
        return answer.split(',').join('、');
      }
      return answer;
    },
    // 判断是否为正确答案
    isCorrectAnswer(question, option) {
      const correctAnswer = question.correctAnswer || question.correct_answer;
      if (!correctAnswer) return false;
      
      if (question.type === 1 || question.type === 'multiple') { // 多选题
        const answers = correctAnswer.split(',');
        return answers.some(answer => answer.trim() === option.trim());
      }
      
      // 单选题、判断题等
      return option.trim() === correctAnswer.trim();
    },
    // 获取预览题目中某题型的数量
    getPreviewCount(type) {
      // 将type转换为字符串进行比较
      const typeStr = type.toString();
      return this.previewQuestions.filter(q => q.type.toString() === typeStr).length;
    },
    // 显示教程提示
    showTutorial() {
      alert('AI题库生成器使用指南:\n\n1. 输入主题关键词\n2. 选择题目数量和难度\n3. 配置需要的题型和数量\n4. 点击"开始生成"按钮\n5. 预览并选择要保存的题目')
    },
 

    // 从预览列表中移除指定索引的题目
    removePreviewQuestion(index) {
        // 从预览列表中移除指定索引的题目
        this.previewQuestions.splice(index, 1)
    },

    
    
    // 生成题型统计摘要
    getQuestionTypesSummary(questions) {
        // 统计每种题型的数量
        const typeCounts = {};
        questions.forEach(q => {
            // 确保类型是数字，方便统一处理
            const type = typeof q.type === 'number' ? q.type : this.mapTypeToNumber(q.type);
            typeCounts[type] = (typeCounts[type] || 0) + 1;
        });
        
        // 转换为易读的格式
        const typeNames = {
            0: '单选题',
            1: '多选题',
            2: '填空题',
            3: '判断题',
            4: '简答题'
        };
        
        // 生成摘要文本
        return Object.entries(typeCounts)
            .map(([type, count]) => `- ${typeNames[type] || `类型${type}`}: ${count}道`)
            .join('\n');
    },
    

   
      // 根据预览题目更新题型配置数量
      updateQuestionTypeCounts() {
          // 计算每种题型的数量
          const typeCounts = {};
          this.questionTypes.forEach(type => {
              typeCounts[type.value] = 0;
          });
          
          // 统计预览中的题型数量
          this.previewQuestions.forEach(q => {
              if (typeCounts[q.type] !== undefined) {
                  typeCounts[q.type]++;
              }
          });
          
          // 更新配置中的题型数量
          Object.keys(typeCounts).forEach(type => {
              this.$set(this.config.questionTypes, type, typeCounts[type]);
          });
      },
      
      // 根据用户选择分配题目数量到各题型
      distributeQuestions() {
          const { questionCount, preferredTypes } = this.quickCreateOptions;
          
          // 确保有选中的题型
          if (preferredTypes.length === 0) {
              preferredTypes.push('single');
          }
          
          // 重置现有题型配置
          const newQuestionTypes = {};
          Object.keys(this.config.questionTypes).forEach(type => {
              newQuestionTypes[type] = 0;
          });
          
          // 平均分配题目
          const baseCount = Math.floor(questionCount / preferredTypes.length);
          let remaining = questionCount - (baseCount * preferredTypes.length);
          
          preferredTypes.forEach(type => {
              newQuestionTypes[type] = baseCount;
              // 分配剩余的题目
              if (remaining > 0) {
                  newQuestionTypes[type]++;
                  remaining--;
              }
          });
          
          // 更新题型配置
          this.config.questionTypes = newQuestionTypes;
      },
      
      // 将前端题型转换为后端数字类型
      mapTypeToNumber(type) {
          // 如果已经是数字，则直接返回
          if (typeof type === 'number') {
              return type;
          }
          
          const typeMap = {
              'single': 0,
              'multiple': 1,
              'fillblank': 2,
              'truefalse': 3,
              'shortanswer': 4
          };
          return typeMap[type] !== undefined ? typeMap[type] : 0;
      },
      
      // 将前端难度转换为后端难度数字
      mapDifficultyToNumber(difficulty) {
          const difficultyMap = {
              'easy': 2, // 简单取中间值2
              'medium': 5, // 中等取中间值5
              'hard': 8 // 困难取中间值8
          };
          return difficultyMap[difficulty] !== undefined ? difficultyMap[difficulty] : 5;
      },
      
    // 处理题目为后端格式
    processQuestionsForBackend(questions) {
        return questions.map(q => ({
            ...q,
            type: this.mapTypeToNumber(q.type),
            difficulty: this.mapDifficultyToNumber(q.difficulty)
        }));
    },
    
    // 处理题目为预览格式（前端显示格式）
    processQuestionsForPreview(questions) {
        return questions.map(q => {
            // 生成唯一ID
            const questionId = `gen-${Date.now()}-${Math.floor(Math.random() * 1000)}`;
            
            return {
                question_id: questionId,
                bank_id: this.bankId,
                type: q.type,
                content: q.content,
                options: q.options,
                correct_answer: q.correct_answer,
                parse: q.parse,
                difficulty: this.config.difficulty,
                generated: true
            };
        });
    },
    // 切换题型选择状态
    togglePreferredType(type) {
        if (this.quickCreateOptions.preferredTypes.includes(type)) {
            this.quickCreateOptions.preferredTypes = this.quickCreateOptions.preferredTypes.filter(t => t !== type);
        } else {
            this.quickCreateOptions.preferredTypes.push(type);
        }
    },
    // 获取选中的题型名称
    getSelectedTypeNames() {
        return this.questionTypes.filter(type => this.quickCreateOptions.preferredTypes.includes(type.value)).map(type => type.label).join(', ');
    },
  },
  // 组件销毁前的钩子函数
  beforeDestroy() {
      // 移除事件总线监听器
      this.$bus.$off('save-questions-to-bank');
      // 清除所有旧的生成记录，确保每次打开组件都是新的开始
      this.resetGenerationState();    
  },
  // 添加created钩子
  created() {
    // 从路由获取数据
    const { data } = this.$route.params;
    console.log('Route query:', this.$route.params);
    console.log("questions:",JSON.parse(data));

    
    if (!data) {
      console.log('No data in route query');
      return;

    }
    const {questions} = JSON.parse(data);
    this.previewQuestions = questions;
    console.log("previewQuestions:",this.previewQuestions);
  },
  // 退出方法
  exit() {
    // 提示用户是否确认退出
    this.$confirm('确定要退出吗？未保存的题目将会丢失', '提示', {
      confirmButtonText: '确定退出',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      // 用户确认退出
      // 清空预览列表
      this.previewQuestions = [];
      // 重置所有配置
      this.resetAllConfig();
      // 显示成功提示
      this.$message({
        type: 'success',
        message: '已退出题目预览',
        duration: 1500
      });
      // 跳转到题库列表页面
      this.$router.push('/question-bank/bank-list');
    }).catch(() => {
      // 用户取消退出，不做任何操作
      this.$message({
        type: 'info',
        message: '已取消退出',
        duration: 1500
      });
    });
  },
}
</script>

<style lang="less" scoped>
@import "@/styles/variables.less";

/* 添加缺少的变量，以防variables.less中没有定义 */
@radius-full: 9999px;
@radius-md: 6px;
@radius-lg: 8px;
@shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
@shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
@shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
@transition: all 0.3s ease;
@secondary: #3A0CA3; /* 紫色作为辅助色 */

.ai-generator-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(5px);
}

.ai-generator-container {
background: white;
border-radius: 16px;
  width: 100%;
  height: 100vh;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  animation: dialogEnter 0.3s ease-out;
  overflow: hidden;
  transition: all 0.3s ease;

  &.fullscreen {
    width: 100%;
    height: 100vh;
    max-width: none;
    border-radius: 0;
  }
}

.ai-generator-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid @gray-200;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #4361EE, #3A0CA3);
  color: white;

  .header-left {
    display: flex;
    align-items: center;
    gap: 1rem;

    h2 {
      margin: 0;
      font-size: 1.25rem;
      font-weight: 600;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      i {
        font-size: 1.2em;
      }
    }

    .ai-status {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 0.875rem;
      opacity: 0.9;

      .pulse-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background-color: #10B981;
        animation: pulse 1.5s infinite;
      }
    }
  }

  .header-actions {
    display: flex;
    gap: 0.5rem;

    .btn-icon {
      background: rgba(255, 255, 255, 0.1);
      border: none;
      width: 36px;
      height: 36px;
      border-radius: 50%;
      color: white;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;

      &:hover {
        background: rgba(255, 255, 255, 0.2);
        transform: scale(1.05);
      }

      &.btn-close:hover {
        background: rgba(239, 68, 68, 0.7);
      }

      i {
        font-size: 1rem;
      }
    }
  }
}

.ai-generator-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.config-panel {
  width: 350px;
  padding: 1.5rem;
  border-right: 1px solid @gray-200;
  background: white;
  transition: all 0.3s ease;
  overflow-y: auto;

  &.collapsed {
    transform: translateX(-100%);
    opacity: 0;
    width: 0;
    padding: 0;
    border: none;
  }

  .panel-section {
    margin-bottom: 2rem;

    h3 {
      font-size: 1rem;
      color: @gray-700;
      margin: 0 0 1.25rem 0;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      i {
        color: @primary;
      }
    }
  }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .form-group {
    label {
      display: block;
      margin-bottom: 0.5rem;
      font-size: 0.875rem;
      font-weight: 500;
      color: @gray-700;
    }

    .input-with-icon {
      position: relative;

      i {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: @gray-500;
        font-size: 0.875rem;
      }
    
    &.textarea-container i {
      top: 12px;
      transform: none;
    }
  }
  
  .input-group {
    position: relative;
    
    label {
        position: absolute;
        left: 12px;
        top: 50%;
        transform: translateY(-50%);
        color: @gray-500;
        font-size: 0.875rem;
      }
    }

    .modern-input {
      width: 100%;
      padding: 0.75rem 1rem 0.75rem 2.5rem;
      border: 1px solid @gray-300;
      border-radius: 8px;
      font-size: 0.875rem;
      transition: all 0.2s ease;
      background-color: @gray-50;

      &:focus {
        outline: none;
        border-color: @primary;
        box-shadow: 0 0 0 3px rgba(@primary, 0.1);
        background-color: white;
      }

      &::placeholder {
        color: @gray-400;
      }
    }

    select.modern-input {
      appearance: none;
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 0.75rem center;
      background-size: 16px 12px;
    }
  }

  .type-config-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .type-config-card {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid @gray-200;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 0.75rem;
    background-color: white;

    &:hover {
      border-color: @primary-light;
      box-shadow: @shadow-sm;
    }

    &.active {
      border-color: @primary;
      background-color: rgba(@primary, 0.05);

      .type-icon {
        color: white;
      }
    }

    .type-icon {
      width: 40px;
      height: 40px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      color: white;
      font-size: 1rem;
      flex-shrink: 0;
    }

    .type-info {
      flex: 1;

      .type-name {
        display: block;
        font-weight: 500;
        color: @gray-800;
        font-size: 0.875rem;
      }

      .type-desc {
        display: block;
        font-size: 0.75rem;
        color: @gray-500;
        margin-top: 0.125rem;
      }
    }

    .type-count {
      display: flex;
      align-items: center;
      gap: 0.5rem;

      .count-btn {
        width: 24px;
        height: 24px;
        border-radius: 4px;
        border: 1px solid @gray-300;
        background: white;
        color: @gray-700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;

        &:hover {
          background: @gray-100;
          color: @primary;
        }

        i {
          font-size: 0.625rem;
        }
      }

      .count-value {
        font-size: 0.875rem;
        font-weight: 500;
        color: @gray-800;
        min-width: 20px;
        text-align: center;
      }
    }
  }

  .total-count {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid @gray-200;
    text-align: center;
    font-size: 0.875rem;
    color: @gray-700;

    .highlight {
      font-weight: 600;
      color: @primary;
      font-size: 1.1em;
    }

    .limit-hint {
      color: @danger;
      font-size: 0.75rem;
      margin-left: 0.5rem;
    }
  }

  .action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 2rem;

    button {
      padding: 0.75rem;
      border-radius: 8px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;
      border: none;
      font-size: 0.9375rem;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
    }

    .btn-generate {
      background: @primary;
      color: white;
      box-shadow: 0 2px 4px rgba(@primary, 0.2);

      &:hover {
        background: darken(@primary, 5%);
        transform: translateY(-1px);
        box-shadow: 0 4px 6px rgba(@primary, 0.2);
      }

      &:disabled {
        background: @gray-400;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
      }
    }
  
  .btn-templates, .btn-quick-create {
      display: flex;
      align-items: center;
      background: white;
      border: 1px solid @gray-200;
      text-align: left;
      justify-content: flex-start;
      padding: 0.75rem 1rem;
      transition: all 0.25s ease;
      overflow: hidden;
      position: relative;
      cursor: pointer;
      border-radius: 8px;
      
      &:hover {
          transform: translateY(-2px);
          border-color: @primary-light;
          box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
          
          .btn-icon-container {
              transform: scale(1.1);
          }
      }
      
      &:before {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          width: 4px;
          height: 100%;
          opacity: 0;
          transition: opacity 0.25s ease;
      }
      
      &:hover:before {
          opacity: 1;
      }
      
      .btn-icon-container {
          width: 36px;
          height: 36px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 50%;
          margin-right: 12px;
          transition: transform 0.25s ease;
          color: white;
      }
      
      .btn-text {
          display: flex;
          flex-direction: column;
      }
      
      .btn-title {
          font-size: 0.9375rem;
          font-weight: 600;
          color: @gray-800;
      }
      
      .btn-desc {
          font-size: 0.8125rem;
          color: @gray-600;
      }
  }
  
  .btn-templates {
      &:before {
          background: linear-gradient(to bottom, #4361EE, #3A0CA3);
      }
      
      .btn-icon-container {
          background: linear-gradient(135deg, #4361EE, #3A0CA3);
      }
  }
  
  .btn-quick-create {
      &:before {
          background: linear-gradient(to bottom, #F59E0B, #FBBF24);
      }
      
      .btn-icon-container {
          background: linear-gradient(135deg, #F59E0B, #FBBF24);
      }
  }
  
  .btn-batch-accept {
      background: @success;
      color: white;
      box-shadow: 0 2px 4px rgba(@success, 0.2);
      
      &:hover {
          background: darken(@success, 5%);
          transform: translateY(-1px);
          box-shadow: 0 4px 6px rgba(@success, 0.2);
      }
    }

    .btn-cancel {
      background: @gray-100;
      color: @gray-700;

      &:hover {
        background: @gray-200;
      }
    }
  }
}

.result-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;

  &.expanded {
    margin-left: 0;
  }

      .result-header {
      padding: 1rem 1.5rem;
      border-bottom: 1px solid @gray-200;
      display: flex;
      justify-content: space-between;
      align-items: center;
      
      .header-actions {
        display: flex;
        gap: 0.35rem;
        align-items: center;
      }
    
    .btn-save {
      display: inline-flex;
      align-items: center;
      padding: 0.5rem 1rem;
      border: none;
      border-radius: 8px;
      background: linear-gradient(135deg, #10B981 0%, #059669 100%);
      color: white;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
      margin-right: 0.35rem;
      
      &:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 6px rgba(16, 185, 129, 0.3);
        background: linear-gradient(135deg, #059669 0%, #047857 100%);
      }
      
      &:active {
        transform: translateY(0);
        box-shadow: 0 1px 2px rgba(16, 185, 129, 0.2);
      }
      
      .btn-content {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        
        i {
          font-size: 0.875rem;
          transition: transform 0.3s ease;
        }
        
        .btn-text {
          font-size: 0.875rem;
        }
      }
      
      &:hover .btn-content i {
        transform: translateY(-1px);
      }
    }
    
    .btn-exit {
      display: inline-flex;
      align-items: center;
      padding: 0.5rem 1rem;
      border: none;
      border-radius: 8px;
      background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
      color: white;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
      box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
      
      &:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 6px rgba(239, 68, 68, 0.3);
        background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
      }
      
      &:active {
        transform: translateY(0);
        box-shadow: 0 1px 2px rgba(239, 68, 68, 0.2);
      }
      
      .btn-content {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        
        i {
          font-size: 0.875rem;
          transition: transform 0.3s ease;
        }
        
        .btn-text {
          font-size: 0.875rem;
        }
      }
      
      &:hover .btn-content i {
        transform: translateX(2px);
      }
    }

    h3 {
      margin: 0;
      font-size: 1rem;
      color: @gray-700;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      i {
        color: @primary;
      }
    }

    .result-stats {
      display: flex;
      gap: 1rem;

      .stat-item {
        display: flex;
        align-items: center;
        gap: 0.5rem;
      }

      .stat-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
        border-radius: 0.5rem;
        color: white;
        font-weight: 500;
      }

      .stat-count {
        font-size: 0.75rem;
        color: @gray-600;
      }
    }
  }

  .result-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
  background-color: @gray-50;
  }

  .generating-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
  
  /* 添加背景微妙变化 */
  background: linear-gradient(135deg, rgba(67, 97, 238, 0.03), rgba(58, 12, 163, 0.05));
  border-radius: 12px;

    .ai-thinking-animation {
      display: flex;
      align-items: center;
      gap: 1.5rem;
      margin-bottom: 2rem;

      .ai-avatar {
        width: 60px;
        height: 60px;
        border-radius: 50%;
      background: linear-gradient(135deg, @primary, @secondary);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.5rem;
      box-shadow: @shadow-md;
      animation: float 3s ease-in-out infinite;
      position: relative;

      &::after {
        content: '';
        position: absolute;
        top: -5px;
        left: -5px;
        right: -5px;
        bottom: -5px;
        border-radius: 50%;
        border: 2px solid rgba(@primary, 0.3);
        animation: pulse 2s infinite;
      }
      }

      .thinking-bubbles {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;

        .bubble {
          background: white;
          padding: 0.75rem 1rem;
          border-radius: 1rem 1rem 1rem 0;
          font-size: 0.875rem;
          color: @gray-700;
          box-shadow: @shadow-sm;
          opacity: 0.5;
          transform: translateY(5px);
        transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        position: relative;
        backdrop-filter: blur(5px);

        &::before {
          content: '';
          position: absolute;
          left: -8px;
          bottom: 0;
          width: 0;
          height: 0;
          border-right: 8px solid white;
          border-top: 8px solid transparent;
          border-bottom: 8px solid transparent;
          filter: drop-shadow(-2px 0 2px rgba(0,0,0,0.1));
          transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
        }

          &.active {
            opacity: 1;
            transform: translateY(0);
            background: @primary;
            color: white;
          font-weight: 500;

          &::before {
            border-right-color: @primary;
          }
          }

          &:nth-child(2) {
            transition-delay: 0.1s;
          }

          &:nth-child(3) {
            transition-delay: 0.2s;
          }

          &:nth-child(4) {
            transition-delay: 0.3s;
          }
        }
      }
    }

    .progress-container {
      width: 100%;
      max-width: 500px;

      .progress-info {
        display: flex;
        justify-content: space-between;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
        color: @gray-600;
      font-weight: 500;
      }

      .progress-bar {
        height: 8px;
        background: @gray-200;
      border-radius: 12px;
        overflow: hidden;
      box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
      }

      .progress-fill {
        height: 100%;
        background: linear-gradient(90deg, @primary, @secondary);
      border-radius: 12px;
        transition: width 0.5s ease;
      position: relative;
      overflow: hidden;

      &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: linear-gradient(90deg,
        rgba(255,255,255,0.1) 25%,
        rgba(255,255,255,0.3) 50%,
        rgba(255,255,255,0.1) 75%);
        background-size: 200% 100%;
        animation: shimmer 2s infinite linear;
      }
      }
    }
  }

  .error-message {
    background: rgba(@danger, 0.1);
    color: @danger;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;

    i {
      font-size: 1rem;
    }
  }

  .questions-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 1.5rem;
    width: 100%;
    padding: 1.5rem;
    
    @media (max-width: 768px) {
      grid-template-columns: 1fr;
    }
  }

  .question-card {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    border-top: 4px solid transparent;
    animation: fadeInUp 0.4s ease-out;

    &.regenerating {
      animation: cardRegenerate 1s ease;
      position: relative;
      
      &::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(255, 255, 255, 0.7);
        backdrop-filter: blur(2px);
        border-radius: 12px;
        z-index: 10;
      }
      
      &::before {
        content: '';
        position: absolute;
        top: 45%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: 3px solid rgba(67, 97, 238, 0.3);
        border-top-color: #4361EE;
        z-index: 11;
        animation: spin 1s linear infinite;
      }

      /* 添加生成中文本 */
      .generating-text {
        position: absolute;
        top: 55%;
        left: 50%;
        transform: translateX(-50%);
        z-index: 11;
        font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
        font-size: 14px;
        font-weight: 500;
        color: #4361EE;
        letter-spacing: 1px;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        animation: pulseText 1.5s infinite ease-in-out;
        white-space: nowrap;
        opacity: 0.9;
      }
    }
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }

    /* 题目类型颜色标识 */
    &.single {
      border-top-color: #4361EE;
      .question-type { background: linear-gradient(135deg, #4361EE, #3A0CA3); }
    }

    &.multiple {
      border-top-color: #3A0CA3;
      .question-type { background: linear-gradient(135deg, #3A0CA3, #7209B7); }
    }

    &.fillblank {
      border-top-color: #F59E0B;
      .question-type { background: linear-gradient(135deg, #F59E0B, #D97706); }
    }

    &.truefalse {
      border-top-color: #10B981;
      .question-type { background: linear-gradient(135deg, #10B981, #059669); }
  }
  
  &.shortanswer {
      border-top-color: #8B5CF6;
      .question-type { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }
    }

    .question-header {
      padding: 0.75rem 1.25rem;  // 减小头部内边距
      display: flex;
      align-items: center;
      gap: 0.5rem;  // 减小元素间距
      background: fade(@gray-100, 50%);
      border-bottom: 1px solid @gray-200;
      
      .question-number {
          font-size: 1rem;  // 稍微减小序号大小
          font-weight: 600;
          color: @gray-700;
          min-width: 24px;  // 减小最小宽度
      }

      .question-type {
        font-size: 0.75rem;
        padding: 0.25rem 0.75rem;  // 减小徽章内边距
          border-radius: @radius-full;
        color: white;
          font-weight: 600;
          display: flex;
          align-items: center;
          gap: 0.25rem;
          box-shadow: @shadow-sm;
          
          i {
              font-size: 0.7rem;
          }
      }

      .question-difficulty {
        font-size: 0.75rem;
        padding: 0.25rem 0.75rem;  // 减小徽章内边距
          border-radius: @radius-full;
        font-weight: 500;
          background: @gray-200;
          color: @gray-700;
          display: flex;
          align-items: center;
          gap: 0.25rem;
          
          i {
              font-size: 0.7rem;
        }
      }
    }

    .question-content {
      padding: 0.75rem 1.25rem;  // 减小内容区内边距
      font-size: 0.875rem;  // 稍微减小字体大小
      color: @gray-800;
      line-height: 1.6;
      position: relative;
      font-weight: 500;
      
      &:before {
          content: "Q";
          position: absolute;
          left: 0.5rem;
          top: 0.5rem;  // 调整背景字母位置
          font-size: 2rem;  // 减小背景字母大小
          font-weight: bold;
          color: fade(@gray-300, 50%);
          z-index: 0;
      }
      
      > * {
          position: relative;
          z-index: 1;
      }
    }

    .question-options {
      padding: 0 1.25rem 0.75rem;  // 减小选项区内边距
      display: flex;
      flex-direction: column;
      gap: 0.5rem;  // 减小选项间距

      .option-item {
          display: flex;
          align-items: center;
          gap: 0.75rem;
          padding: 0.5rem 0.75rem;  // 减小选项内边距
          margin-bottom: 0.125rem;  // 减小选项间距
          border-radius: @radius-md;
          background: @gray-50;
          font-size: 0.875rem;
          transition: all 0.2s ease;
          position: relative;
          border: 1px solid transparent;

          &:hover {
              background: @gray-100;
              transform: translateX(2px);
          }

          &.correct {
              background: rgba(16, 185, 129, 0.1);
              border: 1px solid rgba(16, 185, 129, 0.3);
              color: @gray-900;
              
              .option-content {
                  font-weight: 500;
              }
              
              .correct-indicator {
                  position: absolute;
                  right: 10px;
                  top: 50%;
                  transform: translateY(-50%);
                  color: #10B981;
                  font-size: 1rem;
                  background: rgba(16, 185, 129, 0.1);
                  padding: 2px 6px;
                  border-radius: 4px;
                  display: flex;
                  align-items: center;
                  gap: 4px;
                  
                  i {
                      color: #10B981;
                  }
              }
          }
          
          .option-content {
              flex: 1;
          }
      }
    }

    .question-footer {
      padding: 0.75rem 1.25rem;  // 减小底部内边距
      margin-top: auto;
      border-top: 1px solid @gray-200;
      background: fade(@gray-50, 50%);
      border-radius: 0 0 12px 12px;

      .answer-section {
        font-size: 0.875rem;
        display: flex;
        align-items: flex-start;
        margin-bottom: 0.5rem;  // 减小答案区间距

        .answer-label {
          color: @gray-600;
          margin-right: 0.5rem;
          font-weight: 500;
          white-space: nowrap;
        }

        .answer-value {
          font-weight: 600;
          color: @primary;
          line-height: 1.5;
          flex: 1;
        }
      }
      
      .parse-section {
          padding: 0.5rem 0.75rem;  // 减小解析区内边距
          background: rgba(67, 97, 238, 0.05);
          border-radius: 8px;
          border-left: 3px solid @primary;
          
          .parse-title {
              font-size: 0.875rem;
              font-weight: 600;
              color: @primary;
              margin-bottom: 0.25rem;  // 减小标题下方间距
              display: flex;
              align-items: center;
              gap: 0.375rem;
          
          i {
            font-size: 0.875rem;
            color: @primary;
          }
          }
          
          .parse-content {
              font-size: 0.8125rem;
              color: @gray-700;
              line-height: 1.5;  // 减小行高
              word-break: break-word;
          }
      }

      // 添加AI生成相关的底部操作区域
      .footer-actions {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-top: 1rem;
        padding-top: 0.75rem;
        border-top: 1px dashed @gray-200;

        .ai-generated {
          display: flex;
          align-items: center;
          gap: 0.5rem;
          color: @gray-600;
          font-size: 0.8125rem;

          .ai-icon {
            width: 24px;
            height: 24px;
            border-radius: 6px;
            background: linear-gradient(135deg, #7C3AED, #8B5CF6);
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.75rem;
          }

          .ai-text {
            font-weight: 500;
          }
        }

        .btn-regenerate {
          display: inline-flex;
          align-items: center;
          gap: 0.5rem;
          padding: 0.5rem 0.75rem;
          border-radius: 6px;
          background: white;
          border: 1px solid @gray-300;
          color: @gray-700;
          font-size: 0.8125rem;
          font-weight: 500;
          cursor: pointer;
          transition: all 0.2s ease;
          box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);

          &:hover {
            background: @gray-50;
            border-color: @gray-400;
            transform: translateY(-1px);
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
          }

          &:active {
            transform: translateY(0);
          }

          &.loading {
            opacity: 0.7;
            cursor: wait;
            background: @gray-200;
            pointer-events: none;
            border-color: @gray-300;
            transform: none;
            box-shadow: none;
            
            i {
              color: @primary;
            }
          }

          &:disabled {
            opacity: 0.7;
            cursor: not-allowed;
            pointer-events: none;
          }

          i {
            font-size: 0.75rem;
            color: @gray-600;
            transition: all 0.3s ease;
          }

          .fa-spin {
            animation: spin 1s linear infinite;
          }
        }
      }
    }

    .delete-btn {
      position: absolute;
      top: 10px;
      right: 10px;
      width: 28px;
      height: 28px;
      border-radius: 50%;
      background-color: rgba(255, 255, 255, 0.9);
        display: flex;
      justify-content: center;
        align-items: center;
      cursor: pointer;
      z-index: 10;
      box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
      color: #94a3b8;
      transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
      opacity: 0;
      border: 1px solid rgba(226, 232, 240, 0.8);
      pointer-events: none;
      
      &:hover {
        background-color: #ef4444;
        color: white;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
      }
      
      i {
        font-size: 14px;
      }
    }

    &:hover .delete-btn {
      opacity: 0.85;
      pointer-events: auto;
    }
  }

  @keyframes cardRegenerate {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.98);
    opacity: 0.9;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeInUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;

    .empty-illustration {
      width: 100px;
      height: 100px;
      border-radius: 50%;
      background: @gray-100;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-bottom: 1.5rem;

      i {
        font-size: 2.5rem;
        color: @gray-400;
      }
    }

    h4 {
      font-size: 1.125rem;
      color: @gray-700;
      margin: 0 0 0.5rem 0;
    }

    p {
      font-size: 0.875rem;
      color: @gray-500;
      margin: 0 0 1.5rem 0;
      max-width: 300px;
    }

  .btn-upload-file {
      background: @gray-100;
      color: @gray-700;
      border: none;
      padding: 0.75rem 1.25rem;
      border-radius: 8px;
      font-size: 0.875rem;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      gap: 0.5rem;

      &:hover {
        background: @gray-200;
      color: @primary;
      }

      i {
      font-size: 1.125rem;
      color: @primary;
      }
    }
  }
}

@keyframes cardRegenerate {
  0% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(0.98) rotate(-2deg);
    opacity: 0.7;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes dialogEnter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
0% { transform: scale(1); opacity: 0.8; }
50% { transform: scale(1.1); opacity: 0.5; }
100% { transform: scale(1); opacity: 0.8; }
}

@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}

@keyframes shimmer {
0% {
  background-position: 0% 0%;
  }
  100% {
  background-position: -200% 0%;
}
}

@keyframes fadeInUp {
from {
  opacity: 0;
  transform: translateY(20px);
}
to {
  opacity: 1;
  transform: translateY(0);
}
}

@keyframes fadeInOut {
0%, 100% { opacity: 0.7; }
50% { opacity: 1; }
}

@keyframes spin {
0% { transform: translate(-50%, -50%) rotate(0deg); }
100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (max-width: 1024px) {
  .ai-generator-container {
    width: 95%;
    height: 90vh;
  }

  .config-panel {
    width: 300px;
  }
}

@media (max-width: 768px) {
  .ai-generator-content {
    flex-direction: column;
  }

  .config-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid @gray-200;

    &.collapsed {
      transform: translateY(-100%);
    }
  }

  .result-panel {
    &.expanded {
      margin-left: 0;
      margin-top: 0;
    }
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;

    .result-stats {
      width: 100%;
      overflow-x: auto;
      padding-bottom: 0.5rem;
    }
  }
}

@media (max-width: 480px) {
  .ai-generator-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;

    .header-left {
      flex-direction: column;
      align-items: flex-start;
      gap: 0.25rem;
    }

    .header-actions {
      width: 100%;
      justify-content: flex-end;
    }
  }

  .type-config-card {
    flex-direction: column;
    align-items: flex-start;

    .type-count {
      width: 100%;
      justify-content: flex-end;
      margin-top: 0.5rem;
    }
  }

  .action-buttons {
    flex-direction: row;

    button {
      flex: 1;
  }
}
}

// 新增样式：题库创建区域
.bank-create-section {
  background-color: #f8fafc;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid @gray-200;
  transition: all 0.3s ease;
  
  &:hover {
      border-color: @primary-light;
      box-shadow: 0 2px 8px rgba(67, 97, 238, 0.15);
  }
  
  h3 {
      color: @gray-800;
      margin-bottom: 1.25rem !important;
      
      i {
          color: #4361EE;
      }
  }
  
  .required {
      color: @danger;
      margin-left: 0.25rem;
  }
  
  .text-area {
      min-height: 80px;
      resize: vertical;
      padding: 0.75rem 1rem 0.75rem 2.5rem !important;
      font-family: inherit;
  }
  
  .input-with-icon {
      margin-bottom: 0.75rem;
  }
  
  .modern-input:focus {
      border-color: #4361EE;
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
  }
}

.file-preview {
  background: @gray-100;
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0.75rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid @gray-200;
  
  .file-info {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      overflow: hidden;
      
      i {
          color: @primary;
          font-size: 1.125rem;
      }
      
      .file-name {
          font-weight: 500;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          max-width: 180px;
      }
      
      .file-size {
          color: @gray-600;
          font-size: 0.8125rem;
      }
  }
  
  .btn-remove-file {
      background: transparent;
      border: none;
      color: @gray-600;
      cursor: pointer;
      width: 24px;
      height: 24px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      
      &:hover {
          background: @gray-200;
          color: @danger;
      }
  }
}

.template-selector {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(5px);
  
  .template-modal {
      background: white;
      border-radius: 16px;
      width: 90%;
      max-width: 800px;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
      animation: dialogEnter 0.3s ease-out;
      
      .template-header {
          padding: 1rem 1.5rem;
          border-bottom: 1px solid @gray-200;
          display: flex;
          justify-content: space-between;
          align-items: center;
          background: linear-gradient(135deg, #4361EE, #3A0CA3);
          color: white;
          
          h3 {
              margin: 0;
              font-size: 1.125rem;
              font-weight: 600;
              display: flex;
              align-items: center;
              gap: 0.5rem;
              
              i {
                  font-size: 1.2em;
              }
          }
          
          .template-header-actions {
              display: flex;
              align-items: center;
              gap: 0.5rem;
          }
          
          .btn-refresh {
              background: rgba(255, 255, 255, 0.1);
              border: none;
              width: 36px;
              height: 36px;
              border-radius: 50%;
              color: white;
              cursor: pointer;
              transition: all 0.2s ease;
              display: flex;
              align-items: center;
              justify-content: center;
              
              &:hover:not(:disabled) {
                  background: rgba(255, 255, 255, 0.2);
                  transform: scale(1.05);
              }
              
              &:disabled {
                  opacity: 0.6;
                  cursor: not-allowed;
              }
              
              .fa-spin {
                  animation: spin 1s linear infinite;
              }
              
              i {
                  font-size: 1rem;
              }
          }
          
          .btn-close {
              background: rgba(255, 255, 255, 0.1);
              border: none;
              width: 36px;
              height: 36px;
              border-radius: 50%;
              color: white;
              cursor: pointer;
              transition: all 0.2s ease;
              display: flex;
              align-items: center;
              justify-content: center;
              
              &:hover {
                  background: rgba(255, 255, 255, 0.2);
                  transform: scale(1.05);
              }
              
              i {
                  font-size: 1rem;
              }
          }
      }
  }
  
  .template-content {
      padding: 1.5rem;
      display: flex;
      flex-direction: column;
      gap: 1.25rem;
      max-height: 60vh;
      overflow-y: auto;
      
      .template-intro {
          font-size: 0.95rem;
          color: @gray-700;
          margin: 0 0 0.5rem 0;
          text-align: center;
          font-weight: 400;
          line-height: 1.5;
      }
      
      .template-loading {
          display: flex;
          justify-content: center;
          align-items: center;
          padding: 2rem;
          min-height: 200px;
          
          .loading-animation {
              display: flex;
              flex-direction: column;
              align-items: center;
              gap: 1.5rem;
              text-align: center;
              
              .ai-avatar {
                  width: 60px;
                  height: 60px;
                  border-radius: 50%;
                  background: linear-gradient(135deg, @primary, @secondary);
                  color: white;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  font-size: 1.5rem;
                  box-shadow: @shadow-md;
                  animation: float 3s ease-in-out infinite;
                  position: relative;

                  &::after {
                      content: '';
                      position: absolute;
                      top: -5px;
                      left: -5px;
                      right: -5px;
                      bottom: -5px;
                      border-radius: 50%;
                      border: 2px solid rgba(@primary, 0.3);
                      animation: pulse 2s infinite;
                  }
              }
              
              .loading-text {
                  font-size: 1rem;
                  color: @gray-700;
                  max-width: 300px;
                  animation: fadeInOut 2s ease-in-out infinite;
              }
          }
      }
      
      .template-cards {
          display: grid;
          grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
          gap: 1.25rem;
          
          @media (max-width: 768px) {
              grid-template-columns: 1fr;
          }
      }
      
      .template-card {
          background: white;
          border: 1px solid @gray-200;
          border-radius: 12px;
          padding: 1.25rem;
          box-shadow: @shadow-sm;
          transition: all 0.2s ease;
          display: flex;
          align-items: center;
          gap: 1rem;
          cursor: pointer;
          position: relative;
          overflow: hidden;
          
          &:hover {
              transform: translateY(-2px);
              box-shadow: @shadow-md;
              border-color: @primary-light;
          }
          
          &.selected {
              border: 2px solid @primary;
              background-color: rgba(@primary, 0.05);
              
              .selection-indicator {
                  opacity: 1;
                  transform: scale(1);
                  
                  i {
                      color: @primary;
                  }
              }
              
              .template-icon {
                  background: @primary;
              }
          }
          
          .template-icon {
              width: 48px;
              height: 48px;
              border-radius: 10px;
              display: flex;
              align-items: center;
              justify-content: center;
              background: linear-gradient(135deg, #4361EE, #3A0CA3);
              color: white;
              font-size: 1.25rem;
              flex-shrink: 0;
          }
          
          .template-info {
              flex: 1;
              min-width: 0; /* For text truncation */
              
              .template-name {
                  font-weight: 600;
                  color: @gray-800;
                  font-size: 1rem;
                  margin-bottom: 0.25rem;
                  white-space: nowrap;
                  overflow: hidden;
                  text-overflow: ellipsis;
              }
              
              .template-description {
                  font-size: 0.875rem;
                  color: @gray-600;
                  margin-bottom: 0.75rem;
                  line-height: 1.4;
                  display: -webkit-box;
                  -webkit-line-clamp: 2;
                  -webkit-box-orient: vertical;
                  overflow: hidden;
              }
              
              .template-stats {
                  display: flex;
                  flex-direction: column;
                  gap: 0.5rem;
                  
                  .template-difficulty {
                      font-size: 0.75rem;
                      color: @gray-600;
                      display: flex;
                      align-items: center;
                      gap: 0.5rem;
                      
                      &.easy { color: #10B981; i { color: #10B981; } }
                      &.medium { color: #F59E0B; i { color: #F59E0B; } }
                      &.hard { color: #EF4444; i { color: #EF4444; } }
                      
                      i {
                          font-size: 0.875rem;
                      }
                  }
                  
                  .type-distribution {
                      display: flex;
                      flex-wrap: wrap;
                      gap: 0.5rem;
                      
                      .type-badge {
                          font-size: 0.75rem;
                          padding: 0.25rem 0.5rem;
                          border-radius: 20px;
                          color: white;
                          font-weight: 500;
                          display: inline-flex;
                          align-items: center;
                      }
                  }
              }
          }
          
          }
      }
  }
  
  .quick-create-actions {
      display: flex;
      justify-content: flex-end;
      gap: 1rem;
      padding: 1rem 1.5rem;
      border-top: 1px solid #E5E7EB;
      background-color: white;
      
      .btn-cancel, .btn-quick-generate {
          padding: 0.75rem 1.25rem;
          border-radius: 8px;
          font-weight: 500;
          cursor: pointer;
          transition: all 0.3s ease;
          border: none;
          font-size: 0.9375rem;
          display: flex;
          align-items: center;
          justify-content: center;
          gap: 0.5rem;
      }
      
      .btn-cancel {
          background: #F1F5F9;
          color: #475569;
          
          &:hover {
              background: #E2E8F0;
              transform: translateY(-1px);
          }
          
          i {
              font-size: 0.875rem;
          }
      }
      
      .btn-quick-generate {
          background: linear-gradient(135deg, #F59E0B, #FBBF24);
          color: white;
          box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
          
          &:hover {
              transform: translateY(-2px);
              box-shadow: 0 4px 8px rgba(245, 158, 11, 0.25);
          }
          
          &:active {
              transform: translateY(0);
              box-shadow: 0 1px 2px rgba(245, 158, 11, 0.2);
          }
          
          &:disabled {
              background: #94A3B8;
              cursor: not-allowed;
              transform: none;
              box-shadow: none;
          }
          
          i {
              font-size: 0.875rem;
          }
      }
  }

.range-with-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  
  .range-slider {
      width: 70%;
      
      input[type="range"] {
          width: 100%;
          height: 8px;
          background: #FDE68A;
          border-radius: 4px;
          outline: none;
              transition: all 0.2s ease;
          appearance: none;
          
          &::-webkit-slider-thumb {
              appearance: none;
              width: 18px;
              height: 18px;
              border-radius: 50%;
              background: #F59E0B;
              cursor: pointer;
              border: 2px solid white;
              box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
          }
          
          &::-moz-range-thumb {
              width: 18px;
              height: 18px;
              border-radius: 50%;
              background: #F59E0B;
              cursor: pointer;
              border: 2px solid white;
              box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
          }
      }
  }
  
  .range-display {
      display: flex;
      align-items: center;
      gap: 0.25rem;
      background: white;
      padding: 0.5rem 0.75rem;
      border-radius: 8px;
      border: 1px solid @gray-300;
      min-width: 50px;
      justify-content: center;
      
      .value {
          font-size: 0.875rem;
          font-weight: 600;
          color: #F59E0B;
      }
      
      .unit {
          font-size: 0.75rem;
          color: @gray-600;
      }
  }
}

.difficulty-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  margin: 0.5rem 0;
  
  .difficulty-option {
      flex: 1;
      padding: 0.75rem;
      border-radius: 8px;
      border: 2px solid transparent;
      background: white;
      color: @gray-700;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
      
      &:hover {
          transform: translateY(-1px);
          box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
      }
      
      &.active {
          border-color: currentColor;
          background: rgba(255, 255, 255, 0.7);
          font-weight: 600;
          transform: scale(1.05);
          z-index: 1;
          
          &[class*="easy"] {
              color: #10B981;
              background: rgba(16, 185, 129, 0.08);
          }
          
          &[class*="medium"] {
              color: #F59E0B;
              background: rgba(245, 158, 11, 0.08);
          }
          
          &[class*="hard"] {
              color: #EF4444;
              background: rgba(239, 68, 68, 0.08);
          }
          
          // 移除专家级样式
      }
      
      .difficulty-dot {
          width: 12px;
          height: 12px;
          border-radius: 50%;
      }
  }
}

.type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  
  .type-option {
      flex: 1 0 calc(33.33% - 0.5rem);
      padding: 0.75rem;
      border-radius: 8px;
      border: 1px solid @gray-300;
      background: white;
      color: @gray-700;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      gap: 0.5rem;
      
      &:hover {
          background: @gray-50;
      }
      
      &.active {
          border-width: 2px;
          font-weight: 500;
          
          &.single {
              color: #4361EE;
              border-color: #4361EE;
              background: rgba(67, 97, 238, 0.05);
          }
          
          &.multiple {
              color: #3A0CA3;
              border-color: #3A0CA3;
              background: rgba(58, 12, 163, 0.05);
          }
          
          &.fillblank {
              color: #F59E0B;
              border-color: #F59E0B;
              background: rgba(245, 158, 11, 0.05);
          }
          
          &.truefalse {
              color: #10B981;
              border-color: #10B981;
              background: rgba(16, 185, 129, 0.05);
          }
          
          &.shortanswer {
              color: #8B5CF6;
              border-color: #8B5CF6;
              background: rgba(139, 92, 246, 0.05);
          }
      }
      
      .type-icon {
          width: 24px;
          height: 24px;
          border-radius: 6px;
          display: flex;
          align-items: center;
          justify-content: center;
          color: white;
          flex-shrink: 0;
      }
  }
}

.btn-content {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon-container {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
}

.btn-text {
  display: flex;
  flex-direction: column;
}

.btn-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: @gray-800;
}

.btn-desc {
  font-size: 0.75rem;
  color: @gray-600;
}

.generating-dialog {
}

.template-selector {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(5px);
  
  .template-actions {
      display: flex;
      justify-content: flex-end;
      gap: 1rem;
      padding: 1rem 1.5rem;
      border-top: 1px solid @gray-200;
      background-color: #f8fafc;
      
      .btn-cancel, .btn-apply-template {
          padding: 0.75rem 1.25rem;
          border-radius: 8px;
          font-weight: 500;
          cursor: pointer;
          transition: all 0.2s ease;
          border: none;
          font-size: 0.9375rem;
          display: flex;
          align-items: center;
          justify-content: center;
          gap: 0.5rem;
      }
      
      .btn-cancel {
          background: @gray-100;
          color: @gray-700;
          
          &:hover {
              background: @gray-200;
          }
          
          i {
              font-size: 0.875rem;
          }
      }
      
      .btn-apply-template {
          background: @primary;
          color: white;
          box-shadow: 0 2px 4px rgba(@primary, 0.2);
          
          &:hover {
              background: darken(@primary, 5%);
              transform: translateY(-1px);
              box-shadow: 0 4px 6px rgba(@primary, 0.2);
          }
          
          &:disabled {
              background: @gray-400;
              cursor: not-allowed;
              transform: none;
              box-shadow: none;
          }
          
          i {
              font-size: 0.875rem;
          }
      }
  }
}

.quick-create-panel {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease-out;
  backdrop-filter: blur(5px);
  
  .quick-create-modal {
      background: white;
      border-radius: 16px;
      width: 90%;
      max-width: 800px;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
      animation: dialogEnter 0.3s ease-out;
      
      .quick-create-header {
          padding: 1rem 1.5rem;
          border-bottom: 1px solid @gray-200;
          display: flex;
          justify-content: space-between;
          align-items: center;
          background: linear-gradient(135deg, #F59E0B, #FBBF24);
          color: white;
          
          h3 {
              margin: 0;
              font-size: 1.125rem;
              font-weight: 600;
              display: flex;
              align-items: center;
              gap: 0.5rem;
              
              i {
                  font-size: 1.2em;
              }
          }
          
          .btn-close {
              background: rgba(255, 255, 255, 0.1);
              border: none;
              width: 36px;
              height: 36px;
              border-radius: 50%;
              color: white;
              cursor: pointer;
              transition: all 0.2s ease;
              display: flex;
              align-items: center;
              justify-content: center;
              
              &:hover {
                  background: rgba(255, 255, 255, 0.2);
                  transform: scale(1.05);
              }
              
              i {
                  font-size: 1rem;
          }
      }
  }
  
  .quick-create-content {
      padding: 1.5rem;
      display: flex;
      flex-direction: column;
      gap: 1.25rem;
      max-height: 60vh;
      overflow-y: auto;
      
      .quick-create-intro {
              background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(251, 191, 36, 0.06));
              border-radius: 10px;
              padding: 1.25rem;
              margin: 0 1rem 1.25rem;
              display: flex;
              gap: 1rem;
              position: relative;
              overflow: hidden;
              box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
              border: 1px solid rgba(245, 158, 11, 0.1);
              min-height: 125px;
              
              &::before {
                  content: '';
                  position: absolute;
                  top: -20px;
                  right: -20px;
                  width: 120px;
                  height: 120px;
                  background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.15), transparent 70%);
                  border-radius: 50%;
                  z-index: 0;
              }
              
              .intro-icon {
                  width: 48px;
                  height: 48px;
                  border-radius: 12px;
                  background: linear-gradient(135deg, #F59E0B, #FBBF24);
                  color: white;
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  font-size: 1.25rem;
                  box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
                  position: relative;
                  z-index: 1;
                  flex-shrink: 0;
                  
                  &::after {
                      content: '';
                      position: absolute;
                      top: -3px;
                      left: -3px;
                      right: -3px;
                      bottom: -3px;
                      border-radius: 16px;
                      background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(251, 191, 36, 0.1));
                      z-index: -1;
                      opacity: 0.6;
                  }
              }
              
              .intro-content {
                  flex: 1;
                  position: relative;
                  z-index: 1;
                  
                  h3 {
                      font-size: 1.125rem;
                      font-weight: 600;
                      color: #D97706;
                      margin: 0 0 0.75rem 0;
                  }
                  
                  .intro-features {
                      display: flex;
                      flex-direction: column;
                      gap: 0.5rem;
                      
                      .feature-item {
                          display: flex;
                          align-items: flex-start;
                          gap: 0.5rem;
                          
                          i {
                              color: #F59E0B;
                              font-size: 0.75rem;
                              margin-top: 0.25rem;
                              background: rgba(245, 158, 11, 0.1);
                              padding: 0.25rem;
                              border-radius: 4px;
                              width: 18px;
                              height: 18px;
                              display: flex;
                              align-items: center;
                              justify-content: center;
                          }
                          
                          span {
                              font-size: 0.875rem;
                              color: #4B5563;
          line-height: 1.5;
                          }
                      }
                  }
              }
      }
      
      .quick-create-form {
          display: flex;
          flex-direction: column;
              gap: 1.25rem;
              padding: 0 1rem;
          
          .form-section {
                  background: white;
              padding: 1.25rem;
              border-radius: 10px;
                  border: none;
                  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
                  transition: all 0.3s ease;
                  position: relative;
                  overflow: hidden;
                  
                  &:hover {
                      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
                      transform: translateY(-2px);
                  }
                  
                  &::before {
                      content: '';
                      position: absolute;
                      top: 0;
                      left: 0;
                      width: 4px;
                      height: 100%;
                      background: linear-gradient(to bottom, #F59E0B, #FBBF24);
                  }
              
              .section-title {
                  font-size: 1rem;
                      color: #F59E0B;
                      margin: 0 0 1.25rem 0;
                  display: flex;
                  align-items: center;
                  gap: 0.5rem;
                      font-weight: 600;
                  
                  i {
                      color: #F59E0B;
                          background: rgba(245, 158, 11, 0.1);
                          padding: 0.5rem;
                          border-radius: 8px;
                          font-size: 0.875rem;
                  }
              }
                  
                  label {
                      display: block;
                      margin-bottom: 0.5rem;
                      font-size: 0.875rem;
                      font-weight: 500;
                      color: #374151;
                  }
                  
                  .input-with-icon {
                      position: relative;
                      
                      i {
                          position: absolute;
                          left: 12px;
                          top: 50%;
                          transform: translateY(-50%);
                          color: #6B7280;
                          font-size: 0.875rem;
                      }
                      }
                      
                  .modern-input {
                          width: 100%;
                      padding: 0.625rem 1rem 0.625rem 2.25rem;
                      border: 1px solid #E5E7EB;
                      border-radius: 6px;
                          font-size: 0.875rem;
                          transition: all 0.2s ease;
                          background-color: white;
                          
                          &:focus {
                              outline: none;
                              border-color: #F59E0B;
                              box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
                          }
                          
                          &::placeholder {
                      color: #9CA3AF;
                  }
              }
                  
                  // Tag input styling
                  .tag-input {
                      display: inline-flex;
                  align-items: center;
                      background-color: #eef2ff;
                      border-radius: 6px;
                      padding: 0.5rem 0.75rem;
                      margin-bottom: 0.75rem;
                      max-width: fit-content;
                      color: #3730a3;
                      font-size: 0.875rem;
                      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
                      
                      i {
                          margin-right: 0.5rem;
                          color: #6366f1;
                          font-size: 0.75rem;
                      }
                  }
                  
                  // AI hint text
                  .ai-hint {
                      font-size: 0.8125rem;
                      color: #6b7280;
                      margin: 0.5rem 0 0;
                      padding: 0;
                      line-height: 1.5;
          display: flex;
          align-items: center;
                      gap: 0.375rem;
                      
                      &::before {
                          content: '\f05a';
                          font-family: 'Font Awesome 5 Free';
                          font-weight: 900;
                          color: #9CA3AF;
                          font-size: 0.75rem;
                      }
                  }
                  
                  .option-group {
                      margin-bottom: 1.5rem;
                      
                      &:last-child {
                          margin-bottom: 0;
                      }
  }
}

.range-with-display {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
                  margin-top: 0.25rem;
  
  .range-slider {
                      flex: 1;
      
      input[type="range"] {
          width: 100%;
                          height: 6px;
                          background: linear-gradient(to right, #FCD34D 0%, #F59E0B 100%);
                          border-radius: 10px;
          outline: none;
          transition: all 0.2s ease;
          appearance: none;
          
          &::-webkit-slider-thumb {
              appearance: none;
              width: 18px;
              height: 18px;
              border-radius: 50%;
                              background: white;
              cursor: pointer;
                              border: 2px solid #F59E0B;
              box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
          }
          
          &::-moz-range-thumb {
              width: 18px;
              height: 18px;
              border-radius: 50%;
                              background: white;
              cursor: pointer;
                              border: 2px solid #F59E0B;
              box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
          }
      }
  }
  
  .range-display {
      display: flex;
      align-items: center;
                      justify-content: center;
      gap: 0.25rem;
      background: white;
                      padding: 0.375rem 0.75rem;
                      border-radius: 6px;
                      border: 1px solid #E5E7EB;
                      min-width: 60px;
                      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
      
      .value {
          font-size: 0.875rem;
          font-weight: 600;
          color: #F59E0B;
      }
      
      .unit {
          font-size: 0.75rem;
                          color: #6B7280;
      }
  }
}

.difficulty-selector {
  display: flex;
  align-items: center;
                  gap: 0.75rem;
  flex: 1;
  margin: 0.5rem 0;
  
  .difficulty-option {
      flex: 1;
                      padding: 0.625rem 0.5rem;
                      border-radius: 6px;
                      border: 1px solid #E5E7EB;
      background: white;
                      color: #4B5563;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
                      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
      
      &:hover {
                          background: #F9FAFB;
          transform: translateY(-1px);
      }
      
      &.active {
                          transform: translateY(-2px);
                          box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
          
          &[class*="easy"] {
                              color: #059669;
                              border-color: #10B981;
                              background: rgba(16, 185, 129, 0.05);
          }
          
          &[class*="medium"] {
                              color: #D97706;
                              border-color: #F59E0B;
                              background: rgba(245, 158, 11, 0.05);
          }
          
          &[class*="hard"] {
                              color: #DC2626;
                              border-color: #EF4444;
                              background: rgba(239, 68, 68, 0.05);
          }
      }
      
      .difficulty-dot {
                          width: 10px;
                          height: 10px;
          border-radius: 50%;
      }
  }
}

.type-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  
  .type-option {
      flex: 1 0 calc(33.33% - 0.5rem);
                      padding: 0.75rem 0.625rem;
                      border-radius: 6px;
                      border: 1px solid #E5E7EB;
      background: white;
                      color: #4B5563;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      gap: 0.5rem;
                      box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
      
      &:hover {
                          background: #F9FAFB;
                          transform: translateY(-1px);
      }
      
      &.active {
          border-width: 2px;
          font-weight: 500;
                          transform: translateY(-2px);
                          box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
          
          &.single {
              color: #4361EE;
              border-color: #4361EE;
              background: rgba(67, 97, 238, 0.05);
          }
          
          &.multiple {
              color: #3A0CA3;
              border-color: #3A0CA3;
              background: rgba(58, 12, 163, 0.05);
          }
          
          &.fillblank {
                              color: #D97706;
              border-color: #F59E0B;
              background: rgba(245, 158, 11, 0.05);
          }
          
          &.truefalse {
                              color: #059669;
              border-color: #10B981;
              background: rgba(16, 185, 129, 0.05);
          }
          
          &.shortanswer {
                              color: #7C3AED;
              border-color: #8B5CF6;
              background: rgba(139, 92, 246, 0.05);
          }
      }
      
      .type-icon {
          width: 24px;
          height: 24px;
          border-radius: 6px;
          display: flex;
          align-items: center;
          justify-content: center;
          color: white;
          flex-shrink: 0;
                          font-size: 0.75rem;
                      }
                  }
              }
          }
      }
  }
  
  .quick-create-actions {
      display: flex;
      justify-content: flex-end;
      gap: 1rem;
      padding: 1rem 1.5rem;
      border-top: 1px solid @gray-200;
      background-color: #f8fafc;
      
      .btn-cancel, .btn-quick-generate {
          padding: 0.75rem 1.25rem;
          border-radius: 8px;
          font-weight: 500;
          cursor: pointer;
          transition: all 0.2s ease;
          border: none;
          font-size: 0.9375rem;
  display: flex;
  align-items: center;
          justify-content: center;
  gap: 0.5rem;
}

      .btn-cancel {
          background: @gray-100;
          color: @gray-700;
          
          &:hover {
              background: @gray-200;
          }
          
          i {
              font-size: 0.875rem;
          }
      }
      
      .btn-quick-generate {
          background: #F59E0B;
          color: white;
          box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
          
          &:hover {
              background: darken(#F59E0B, 5%);
              transform: translateY(-1px);
              box-shadow: 0 4px 6px rgba(245, 158, 11, 0.2);
          }
          
          &:active {
              transform: translateY(0);
              box-shadow: 0 1px 2px rgba(245, 158, 11, 0.2);
          }
          
          &:disabled {
              background: @gray-400;
              cursor: not-allowed;
              transform: none;
              box-shadow: none;
          }
          
          i {
              font-size: 0.875rem;
          }
      }
  }
}

.ai-suggestion {
  display: flex;
  gap: 1rem;
  background: white;
  padding: 1.25rem;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  margin: 0 1rem 1.25rem;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  border-left: 4px solid #7C3AED;
  min-height: 95px;
  
  &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
  }
  
  .ai-suggestion-icon {
  display: flex;
  align-items: center;
  justify-content: center;
      width: 38px;
      height: 38px;
      border-radius: 10px;
      background: linear-gradient(135deg, #7C3AED, #8B5CF6);
  color: white;
      font-size: 1rem;
      flex-shrink: 0;
      box-shadow: 0 2px 4px rgba(124, 58, 237, 0.2);
  }
  
  .ai-suggestion-content {
      flex: 1;
      
      .ai-suggestion-title {
          font-weight: 600;
          color: #7C3AED;
          margin-bottom: 0.375rem;
          font-size: 0.9375rem;
  display: flex;
          align-items: center;
          gap: 0.5rem;
}

      .ai-suggestion-text {
  font-size: 0.875rem;
          color: #4B5563;
          line-height: 1.6;
      }
  }
}

.file-upload-hint {
  margin-top: 10px;
  color: #666;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid #1890ff;
}

.file-upload-hint i {
  margin-right: 8px;
  color: #1890ff;
}

/* 按钮加载状态 */
.btn-action.loading {
  opacity: 0.7;
  cursor: wait;
  background-color: #6B7280;
}

/* 按钮加载状态 */
.btn-action.btn-regenerate.loading {
  opacity: 0.7;
  cursor: wait;
  background-color: #6B7280;
  
  &:hover {
      background-color: #6B7280;
      transform: none;
  }
}

/* 重设旋转动画 */
.fa-spin {
  animation: fa-spin 1s linear infinite;
}

@keyframes fa-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 关键词标签样式 */
.keyword-tags {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 0.75rem;
min-height: 32px;

.keyword-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: rgba(67, 97, 238, 0.1);
  color: #4361EE;
  border-radius: 9999px;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid rgba(67, 97, 238, 0.2);
  animation: tagEnter 0.3s ease-out;

  &:hover {
    background: rgba(67, 97, 238, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

    i.fa-times {
      color: #ef4444;
    }
  }

  i {
    font-size: 0.7rem;
    color: #4361EE;
    transition: color 0.2s ease;
    
    &.fa-tag {
      margin-right: 2px;
    }
    
    &.fa-times {
      margin-left: 2px;
    }
  }

  &.tag-highlight {
    animation: tagHighlight 1s ease-out;
  }
}
}

/* 标签动画 */
@keyframes tagEnter {
from {
  opacity: 0;
  transform: translateY(10px) scale(0.8);
}
to {
  opacity: 1;
  transform: translateY(0) scale(1);
}
}

@keyframes tagHighlight {
0% {
  transform: scale(1);
  box-shadow: 0 0 0 0 rgba(@primary, 0.4);
}
50% {
  transform: scale(1.1);
  box-shadow: 0 0 0 10px rgba(@primary, 0);
}
100% {
  transform: scale(1);
  box-shadow: 0 0 0 0 rgba(@primary, 0);
}
}

/* 标签过渡动画 */
.tag-fade-enter-active, .tag-fade-leave-active {
transition: all 0.3s ease;
}

.tag-fade-enter, .tag-fade-leave-to {
opacity: 0;
transform: translateY(10px) scale(0.8);
}

.tag-fade-move {
transition: transform 0.3s ease;
}

/* 题目卡片删除按钮样式 */
.delete-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  color: #94a3b8;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  border: 1px solid rgba(226, 232, 240, 0.8);
  pointer-events: none;
  
  &:hover {
      background-color: #ef4444;
      color: white;
      transform: translateY(-2px);
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  }
  
  i {
      font-size: 14px;
  }
}

.question-card:hover .delete-btn {
  opacity: 0.85;
  pointer-events: auto;
}

.quick-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2rem;
  
  .btn-templates, .btn-quick-create {
      display: flex;
      align-items: center;
      background: white;
      border: 1px solid @gray-200;
      text-align: left;
      justify-content: flex-start;
      padding: 0.75rem 1rem;
      transition: all 0.25s ease;
      overflow: hidden;
      position: relative;
      cursor: pointer;
      border-radius: 8px;
      
      &:hover {
          transform: translateY(-2px);
          border-color: @primary-light;
          box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);

.btn-icon-container {
              transform: scale(1.1);
          }
      }
      
      &:before {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          width: 4px;
          height: 100%;
          opacity: 0;
          transition: opacity 0.25s ease;
      }
      
      &:hover:before {
          opacity: 1;
      }
      
      .btn-icon-container {
          width: 36px;
          height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
          margin-right: 12px;
          transition: transform 0.25s ease;
  color: white;
}

.btn-text {
  display: flex;
  flex-direction: column;
}

.btn-title {
          font-size: 0.9375rem;
  font-weight: 600;
  color: @gray-800;
}

.btn-desc {
          font-size: 0.8125rem;
  color: @gray-600;
      }
  }
  
  .btn-templates {
      &:before {
          background: linear-gradient(to bottom, #4361EE, #3A0CA3);
      }
      
      .btn-icon-container {
          background: linear-gradient(135deg, #4361EE, #3A0CA3);
      }
  }
  
  .btn-quick-create {
      &:before {
          background: linear-gradient(to bottom, #F59E0B, #FBBF24);
      }
      
      .btn-icon-container {
          background: linear-gradient(135deg, #F59E0B, #FBBF24);
    }
  }
}

@keyframes pulseText {
  0%, 100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}
</style>